package com.wicket.okrrbff.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrcomponent.common.exception.BizException;
import com.wicket.okrrbff.biz.service.OssService;
import com.wicket.okrrbff.biz.service.dto.req.*;
import com.wicket.okrrbff.biz.service.dto.res.*;
import com.wicket.okrrbff.common.ro.OkrResult;
import com.wicket.okrrbff.common.ro.OkrResult;
import com.wicket.okrrbff.common.util.CommonFunctionHelper;
import com.wicket.okrrbff.common.util.RedisUtil;
import javax.annotation.Resource;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import com.wicket.okrcomponent.integration.FwCompOssClient;
import com.wicket.okrcomponent.integration.dto.QueryObjectStorageTemporaryCredentialsDetailComRespDto;
import com.wicket.okrcomponent.integration.dto.QueryObjectStorageTemporaryCredentialsDetailComReqDto;

import java.util.ArrayList;
import java.util.List;
import com.wicket.okrcomponent.integration.dto.QueryStorageTemporaryCredentialsDetailComRespDto;
import com.wicket.okrcomponent.integration.dto.QueryStorageTemporaryCredentialsDetailComReqDto;
import com.wicket.okrrbff.common.exception.Assert;
import com.wicket.okrcomponent.integration.FwCompResourceFileClient;
import com.wicket.okrcomponent.integration.dto.LoopSetResourceFileComRespDto;
import com.wicket.okrcomponent.integration.dto.LoopSetResourceFileComReqDto;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class OssServiceImpl implements OssService {

  @Resource
  private RedisUtil redisUtil;
@Resource
  FwCompOssClient fwCompOssClient;
@Resource
  FwCompResourceFileClient fwCompResourceFileClient;
/**
   * B8查询存储临时访问令牌[10412]
   * gen by moon at 12/7/2024, 9:30:26 PM
   */
    @Trace(operationName = "B8查询存储临时访问令牌")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffQueryObjectStorageTemporaryCredentialsDetailRespDto queryObjectStorageTemporaryCredentialsDetail(BffQueryObjectStorageTemporaryCredentialsDetailReqDto reqDto){

       
       LoopSetResourceFileComRespDto loopSetResourceFileComRespDto_1 =null;
       QueryStorageTemporaryCredentialsDetailComRespDto queryStorageTemporaryCredentialsDetailComRespDto_1 =null;
//步骤0: D2循环生成资源文件相对路径并缓存相对路径(公共) - loopSetResourceFileCom
     LoopSetResourceFileComRespDto loopSetResourceFileComRespDto = null;
    LoopSetResourceFileComReqDto loopSetResourceFileComReqDto=new LoopSetResourceFileComReqDto();
  loopSetResourceFileComReqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID//sourceId:2031588_1
loopSetResourceFileComReqDto.setUserId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecUserId());//CURRENT_USERID//sourceId:2031589_1
if(reqDto!=null){
      loopSetResourceFileComReqDto.setPlatformOrTenantDoc(reqDto.getPlatformOrTenantDoc());//SimpleFieldAssign//sourceId:2031584_1
loopSetResourceFileComReqDto.setDocUseType(reqDto.getDocUseType());//SimpleFieldAssign//sourceId:2031587_1
loopSetResourceFileComReqDto.setResourceFileList(reqDto.getResourceFileList());//list-field-assign//sourceId:2031597_1
    }

    /*D2循环生成资源文件相对路径并缓存相对路径(公共)[10413]   */
    Assert.isNull(loopSetResourceFileComReqDto.getPlatformOrTenantDoc(),"B8查询存储临时访问令牌-D2循环生成资源文件相对路径并缓存相对路径(公共)-平台或租户文档不能为空",false);
Assert.isNull(loopSetResourceFileComReqDto.getDocUseType(),"B8查询存储临时访问令牌-D2循环生成资源文件相对路径并缓存相对路径(公共)-文档用途类型不能为空",false);
Assert.isNull(loopSetResourceFileComReqDto.getSpaceId(),"B8查询存储临时访问令牌-D2循环生成资源文件相对路径并缓存相对路径(公共)-空间ID不能为空",false);
Assert.isNull(loopSetResourceFileComReqDto.getUserId(),"B8查询存储临时访问令牌-D2循环生成资源文件相对路径并缓存相对路径(公共)-个人账号不能为空",false);
      loopSetResourceFileComRespDto = fwCompResourceFileClient.loopSetResourceFileCom(loopSetResourceFileComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


      loopSetResourceFileComRespDto_1 = loopSetResourceFileComRespDto;

//步骤1: D2查询对象存储临时令牌详情(公共) - queryStorageTemporaryCredentialsDetailCom
     QueryStorageTemporaryCredentialsDetailComRespDto queryStorageTemporaryCredentialsDetailComRespDto = null;
    if(loopSetResourceFileComRespDto !=null){
    QueryStorageTemporaryCredentialsDetailComReqDto queryStorageTemporaryCredentialsDetailComReqDto=new QueryStorageTemporaryCredentialsDetailComReqDto();
  queryStorageTemporaryCredentialsDetailComReqDto.setOriginalRoleMemberId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecOriginalRoleMemberId());//CURRENT_ORIGINAL_ROLE_MEMBERID//sourceId:2031218_1
if(loopSetResourceFileComRespDto!=null){
      queryStorageTemporaryCredentialsDetailComReqDto.setResourceFileList(loopSetResourceFileComRespDto.getResourceFileList());//list-field-assign//sourceId:2033555_1
    }

    /*D2查询对象存储临时令牌详情(公共)[10409]   */
    Assert.isNull(queryStorageTemporaryCredentialsDetailComReqDto.getOriginalRoleMemberId(),"B8查询存储临时访问令牌-D2查询对象存储临时令牌详情(公共)-身份人员ID不能为空",false);
      queryStorageTemporaryCredentialsDetailComRespDto = fwCompOssClient.queryStorageTemporaryCredentialsDetailCom(queryStorageTemporaryCredentialsDetailComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;
      

      queryStorageTemporaryCredentialsDetailComRespDto_1 = queryStorageTemporaryCredentialsDetailComRespDto;
           }

BffQueryObjectStorageTemporaryCredentialsDetailRespDto retData = new BffQueryObjectStorageTemporaryCredentialsDetailRespDto();
  if(queryStorageTemporaryCredentialsDetailComRespDto_1!=null){
retData.setEndPoint(queryStorageTemporaryCredentialsDetailComRespDto_1.getEndPoint());//SimpleFieldAssign//sourceId:2031233_1
retData.setReviewUrl(queryStorageTemporaryCredentialsDetailComRespDto_1.getReviewUrl());//SimpleFieldAssign//sourceId:2031234_1
retData.setBucketName(queryStorageTemporaryCredentialsDetailComRespDto_1.getBucketName());//SimpleFieldAssign//sourceId:2031235_1
retData.setAliyunTemporaryIdentityKey(queryStorageTemporaryCredentialsDetailComRespDto_1.getAliyunTemporaryIdentityKey());//SimpleFieldAssign//sourceId:2031236_1
retData.setAliyunTemporaryIdentitySec(queryStorageTemporaryCredentialsDetailComRespDto_1.getAliyunTemporaryIdentitySec());//SimpleFieldAssign//sourceId:2031237_1
retData.setAliyunTemporaryIdentityToken(queryStorageTemporaryCredentialsDetailComRespDto_1.getAliyunTemporaryIdentityToken());//SimpleFieldAssign//sourceId:2031238_1
retData.setAliyunUploadAuthorizationPolicy(queryStorageTemporaryCredentialsDetailComRespDto_1.getAliyunUploadAuthorizationPolicy());//SimpleFieldAssign//sourceId:2031239_1
retData.setAliyunUploadSignature(queryStorageTemporaryCredentialsDetailComRespDto_1.getAliyunUploadSignature());//SimpleFieldAssign//sourceId:2031240_1
retData.setObjectStorageTemporaryCredentialsList(queryStorageTemporaryCredentialsDetailComRespDto_1.getObjectStorageTemporaryCredentialsList());//list-field-assign//sourceId:2033565_1
    }
if(loopSetResourceFileComRespDto_1!=null){
      retData.setResourceFileList(loopSetResourceFileComRespDto_1.getResourceFileList());//list-field-assign//sourceId:2031599_1
        }


  
  
return retData;
  }
  //
}
